// 新建窗口
import { ipcMain,dialog } from 'electron'
import { WindowCreator } from '../hooks/createdWindow'

let win: WindowCreator | null = null
const createWindow = (name: string) => {
  //判断是否创建过窗口,如果创建过置顶
  if (win && win.window && !win.window.isDestroyed()) {
    win.show()
    return
  }


  // 创建新窗口
  win = new WindowCreator({
    title: name,
    width: 600,
    height: 500,
    entry: 'index.html#/settingPage',

  })
  //出现一个弹窗
  //打印当前路径

  dialog.showMessageBox({
    type: 'info',
    title: '提示',
    message: `index.html#/settingPage`,
    buttons: ['确定']
  })




  win.show()
}
// 注册设置窗口页面
function settingWindow() {
  ipcMain.handle('setting-windows', async (_, name: string) => {
    createWindow(name || '设置')


  })
}


export default {
  settingWindow
}
